package pl.elka.simulator.gui;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.util.List;

import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import pl.elka.simulator.core.configurationCommand.ConfigurationCommandType;
import pl.elka.simulator.mediator.ActionResult;
import pl.elka.simulator.mediator.ActionType;
import pl.elka.simulator.mediator.ActionValue;
import pl.elka.simulator.mediator.SimulationFasade;

public class ConfigurationPanel extends JPanel{

	public ConfigurationPanel(){
		setLayout(new BoxLayout(this,BoxLayout.Y_AXIS) );
	}
	public void regenerateContent(String mobilityManagerId) {
		removeAll();
		ButtonGroup group = new ButtonGroup();
		JPanel radioPanel = new JPanel(new GridLayout(0, 1));
		 
		ActionResult result = SimulationFasade.getInstance().handleAction(ActionType.GetAllowedConfigurationCommands, new ActionValue(mobilityManagerId));
		List<ConfigurationCommandType> commandTypes = (List<ConfigurationCommandType>)result.getResult();
		for(ConfigurationCommandType t:commandTypes){
			JRadioButton jrb = new JRadioButton(t.toString());
			jrb.addActionListener(new ChooseConfigurationCommandTypeListener(t));
			group.add(jrb);
			radioPanel.add(jrb);
		}
		add(radioPanel, BorderLayout.LINE_START);
		revalidate();
	}	

}
